78d744391afaddf098f9bd874b4e3379bc9907bf,main/plugins/org.talend.mdm.commmon/src/org/talend/mdm/commmon/metadata/MetadataRepository.java,MetadataRepository,visitElement,#XSDElementDeclaration#,469

Before Change


    public void visitElement(XSDElementDeclaration element) {
        if (currentTypeStack.isEmpty()) { // "top level" elements means new MDM entity type
            String typeName = element.getName();
            if (entityTypes.get(getUserNamespace()) != null) {
                if (entityTypes.get(getUserNamespace()).containsKey(typeName)) {
                    // Ignore another definition (already processed).
                    return;
                }
            }
            // Id fields
            Map<String, XSDXPathDefinition> idFields = new LinkedHashMap<String, XSDXPathDefinition>();
            EList<XSDIdentityConstraintDefinition> constraints = element.getIdentityConstraintDefinitions();
            for (XSDIdentityConstraintDefinition constraint : constraints) {
                EList<XSDXPathDefinition> fields = constraint.getFields();
                for (XSDXPathDefinition field : fields) {
                    idFields.put(field.getValue(), field);
                }
            }
            ComplexTypeMetadata type = getComplexType(typeName); // Take type from repository if already built
            if (type == null) {
                XmlSchemaAnnotationProcessorState state;
                try {
                    XSDAnnotation annotation = element.getAnnotation();
                    state = new XmlSchemaAnnotationProcessorState();
                    for (XmlSchemaAnnotationProcessor processor : XML_ANNOTATIONS_PROCESSORS) {
                        processor.process(this, null, annotation, state);
                    }
                } catch (Exception e) {
                    throw new RuntimeException("Annotation processing exception while parsing info for type '" + typeName + "'.",
                            e);
                }
                // If write is not allowed for everyone, at least add "administration".
                if (state.getAllowWrite().isEmpty()) {
                    state.getAllowWrite().add(ICoreConstants.ADMIN_PERMISSION);
                }
                type = new ComplexTypeMetadataImpl(targetNamespace, typeName, state.getAllowWrite(), state.getDenyCreate(),
                        state.getHide(), state.getDenyPhysicalDelete(), state.getDenyLogicalDelete(), state.getSchematron(),
                        state.getPrimaryKeyInfo(), state.getLookupFields(), true, state.getWorkflowAccessRights());
                // Keep line and column of definition
                type.setData(XSD_LINE_NUMBER, XSDParser.getStartLine(element.getElement()));
                type.setData(XSD_COLUMN_NUMBER, XSDParser.getStartColumn(element.getElement()));
                type.setData(XSD_DOM_ELEMENT, element.getElement());
                addTypeMetadata(type);

After Change


    public void visitElement(XSDElementDeclaration element) {
        if (currentTypeStack.isEmpty()) { // "top level" elements means new MDM entity type
            String typeName = element.getName();
            if (getComplexType(typeName) != null) { // Don't process twice type
                return;
            }
            // Id fields
            Map<String, XSDXPathDefinition> idFields = new LinkedHashMap<String, XSDXPathDefinition>();
            EList<XSDIdentityConstraintDefinition> constraints = element.getIdentityConstraintDefinitions();
            for (XSDIdentityConstraintDefinition constraint : constraints) {
                EList<XSDXPathDefinition> fields = constraint.getFields();
                for (XSDXPathDefinition field : fields) {
                    idFields.put(field.getValue(), field);
                }
            }
            XmlSchemaAnnotationProcessorState state;
            try {
                XSDAnnotation annotation = element.getAnnotation();
                state = new XmlSchemaAnnotationProcessorState();
                for (XmlSchemaAnnotationProcessor processor : XML_ANNOTATIONS_PROCESSORS) {
                    processor.process(this, null, annotation, state);
                }
            } catch (Exception e) {
                throw new RuntimeException("Annotation processing exception while parsing info for type '" + typeName + "'.",
                        e);
            }
            // If write is not allowed for everyone, at least add "administration".
            if (state.getAllowWrite().isEmpty()) {
                state.getAllowWrite().add(ICoreConstants.ADMIN_PERMISSION);
            }
            ComplexTypeMetadata type = new ComplexTypeMetadataImpl(targetNamespace, typeName, state.getAllowWrite(), state.getDenyCreate(),
                    state.getHide(), state.getDenyPhysicalDelete(), state.getDenyLogicalDelete(), state.getSchematron(),
                    state.getPrimaryKeyInfo(), state.getLookupFields(), true, state.getWorkflowAccessRights());
            // Keep line and column of definition
            type.setData(XSD_LINE_NUMBER, XSDParser.getStartLine(element.getElement()));
            type.setData(XSD_COLUMN_NUMBER, XSDParser.getStartColumn(element.getElement()));
            type.setData(XSD_DOM_ELEMENT, element.getElement());
            addTypeMetadata(type);